class Solution {
public:
    int search(vector<int>& nums, int target) 
    {
        int low = 0;
        int height = nums.size() - 1;

        while(low <= height)
        {
            int mid = (low + height) / 2;

            if(nums[mid] == target)
                return mid;
            else if(nums[mid] > target)
                height = mid - 1;
            else low = mid + 1;

        }

        return -1;
    }
};

//数据量小的情况下使用直接遍历法时间更短